# ----------------------------- #
#    Create data for analysis   #
# ----------------------------- #

## Clear working space
rm(list = ls())
options(stringsAsFactors = FALSE)
seed_to_use <- 216
set.seed(seed_to_use)

## Check missing packages
list.of.packages <- c("plyr", "dplyr", "parallel", "missForest", "ggplot2", "FactoMineR")
new.packages <- list.of.packages[!(list.of.packages %in% installed.packages()[,"Package"])]
if(length(new.packages)) install.packages(new.packages)

## Set the libraries for replication
library(plyr)
library(dplyr)
library(parallel)
library(missForest)
library(ggplot2)
library(FactoMineR)

## Unique to each user
your_working_directory <- "marcus_oil/replication_code" 
setwd(your_working_directory)

## Import data
oil_melt32 <- read.csv("oil_32_data_cleaned.csv")



## Impute data
source("programs/imputation_oil_replication.R")

## Load in  imputed data
load("imputed_values/oil_data_32_imputed.rda")

## Csv
write.csv(oil_data_32_imputed, file = "imputed_values/oil_data_32_imputed.csv")

